<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        
        .swiper {
            position: relative;
            width: 640px;
            height: 360px;
            margin: 100px auto;
            border: 1px solid #ccc;
        }
        
        .img-box {
            position: absolute;
            width: 640px;
            height: 100%;
            transition: all 2s;
            transform-style: preserve-3d;
        }
        
        .img {
            position: absolute;
            width: 100%;
            height: 100%;
        }
        
        .img:nth-child(1) {
            background: url(images/01.jpg) no-repeat;
            transform: translateZ(180px);
        }
        
        .img:nth-child(2) {
            background: url(images/02.jpg) no-repeat;
            transform: rotateX(-90deg) translateZ(180px);
        }
        
        .img:nth-child(3) {
            background: url(images/03.jpg) no-repeat;
            transform: rotateX(-180deg) translateZ(180px);
        }
        
        .img:nth-child(4) {
            background: url(images/04.jpg) no-repeat;
            transform: rotateX(-270deg) translateZ(180px);
        }
        
        .btn {
            display: block;
            width: 100px;
            margin: 0 auto;
        }
    </style>
</head>

<body>
    <div class="swiper">
        <div class="img-box">
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
            <div class="img"></div>
        </div>
    </div>
    <input type="button" value="点击下一张" class="btn">
</body>
<script src='js/jquery.min.js'></script>
<script>
    var count = 0;
    var lock = false;
    // btn的点击事件
    $('.btn').click(function() {
        if (lock) {
            return
        };
        lock = true;
        setTimeout(function() {
            lock = false
        }, 2000);
        $('.img-box').css({
            'transform': `rotateX(${--count*90}deg)`,
        })
    });
    // 开启定时器
    var timer = setInterval(move, 2000);

    // 鼠标移进或移出盒子时,定时器的清除和重新添加
    $('.btn').hover(function() {
        clearInterval(timer)
    }, function() {
        timer = setInterval(move, 2000);
    });
    // 封装move函数
    function move() {
        $('.img-box').css({
            'transform': `rotateX(${--count*90}deg)`,
        })
    };
</script>

</html>